-
-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[automation] Added automation script StartLevels #2222
Conversation
acd14d6
to
033eecd
Compare
Can you provide an example of how the script accomplishes this? |
I provided two mechanisms - either in the name of the script or the folder that contains it. So to run at start level 60:
Happy to add documentation changes to the PR too, but I'm not sure where it goes. |
Found the docs at https://github.com/openhab/openhab-docs/blob/main/configuration/jsr223.md Happy to create a PR for this too, just want to ensure that the maintainers are happy with this change before I do so. (I also see that the current docs describe the loading order, which is no longer correct as of OH3.x) |
2deb01e
to
03c3727
Compare
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/use-start-level-reached-in-rule-file/118683/14 |
467f333
to
f9c2635
Compare
slTrackers.remove(tracker); | ||
} | ||
|
||
public interface StartLevelTracker { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I deliberately didn't introduce a dedicated tracker here as it somewhat duplicates the already existing ReadyTracker
- this service can be used to track start level changes, see this example.
Would you be ok to refactor your PR accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kaikreuzer sure! I've just pushed an update which switches to that patttern. Hope that is better.
(BTW I originally added the dedicated tracker to the StartLevelService because I didn't want to replicate the functionality that it provided - e.g. storing all the ready markers and determining the singular current start level. I've just used a much simpler implementation however.)
Allows scripts to specify per-script start levels which differ from the start level for the ScriptFileWatcher itself. Also extracted some functionality from ScriptFileWatcher into distinct components & added unit tests to cover all script loading functionality. Signed-off-by: Jonathan Gilbert <[email protected]>
f9c2635
to
a55a81d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jpg0, lgtm!
And yes, it would be awesome if you could create a PR for the docs repo to cover this new feature there - thanks!
import java.util.regex.Pattern; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.jetbrains.annotations.NotNull; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use jetbrains null annotations.
See https://www.openhab.org/docs/developer/guidelines.html#null-annotations
Can you do a follow up PR with adding proper null annotations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that! IDEA can be very keen on adding these sometimes; I hadn't noticed. I'll create a follow up PR to remove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
|
||
@NotNull | ||
@Override | ||
public <V> ScheduledFuture<V> schedule(@NotNull Callable<V> callable, long delay, @NotNull TimeUnit unit) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the jetbrains @NotNull
annotations in this file should be replaced with Eclipse JDT annotaitons.
Good catches, @wborn, sorry for having merged without noticing. 😲 |
Those jetbrains annotations seem to be a dependency of hivemq-mqtt-client. Maybe we can exclude it to prevent it from happening. They've ended up in some add-ons too (openhab/openhab-addons#10334). |
PR to remove the introduced annotations: #2241 |
@wborn Can we add a build step to reject imports from the |
SAT already scans for forbidden packages. But it will only result in warnings and not errors, so we could add the package to ruleset.properties Excluding the dependency from hivemq-mqtt-client would also introduce another hurdle for using them. 😉 |
JSR223 scripts can now be run at specific start levels as of openhab/openhab-core#2222 This PR adds the docs to describe how it can be used.
JSR223 scripts can now be run at specific start levels as of openhab/openhab-core#2222 This PR adds the docs to describe how it can be used. Signed-off-by: Jonathan Gilbert <[email protected]>
PR for doc changes: openhab/openhab-docs#1511 |
* Startlevel execution support for jsr223 scripts JSR223 scripts can now be run at specific start levels as of openhab/openhab-core#2222 This PR adds the docs to describe how it can be used. Signed-off-by: Jonathan Gilbert <[email protected]> * Add linebreaks. Signed-off-by: Jerome Luckenbach <[email protected]> Co-authored-by: Jerome Luckenbach <[email protected]>
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/graalvm-for-automation/84116/21 |
Allows scripts to specify per-script start levels which differ from the start level for the ScriptFileWatcher itself. Also extracted some functionality from ScriptFileWatcher into distinct components & added unit tests to cover all script loading functionality. Signed-off-by: Jonathan Gilbert <[email protected]> GitOrigin-RevId: 635b700
Allows scripts to specify per-script start levels (which differ from the start level for the
ScriptFileWatcher
itself). Also extracted various functionality from ScriptFileWatcher into distinct components & added unit tests to cover all script loading functionality.This fixes #2002 and possibly #1983 too. The vast majority of the new LOC are unit tests.
Signed-off-by: jpg0 [email protected]